package lc.smart.android.main;

import android.annotation.SuppressLint;
import android.app.ActionBar;
import android.app.ActionBar.Tab;
import android.app.Activity;
import android.app.FragmentTransaction;
import android.os.Bundle;
import android.view.Menu;

public class MyActionBarActivity extends Activity
{

	@SuppressLint("NewApi")
	@Override
	protected void onCreate(Bundle savedInstanceState)
	{
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_action_bar);
		ActionBar actionBar = getActionBar();
		//选项卡
		actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
		//		actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP,
		//				ActionBar.DISPLAY_HOME_AS_UP);
		actionBar.addTab(actionBar.newTab().setText("Tab 1")
				.setTabListener(tabListener));
		actionBar.addTab(actionBar.newTab().setText("Tab 2")
				.setTabListener(tabListener));
		actionBar.addTab(actionBar.newTab().setText("Tab 3")
				.setTabListener(tabListener));

	}

	private ActionBar.TabListener tabListener = new ActionBar.TabListener()
	{

		@Override
		public void onTabReselected(Tab tab, FragmentTransaction ft)
		{
			// TODO Auto-generated method stub

		}

		@Override
		public void onTabSelected(Tab tab, FragmentTransaction ft)
		{
			// TODO Auto-generated method stub

		}

		@Override
		public void onTabUnselected(Tab tab, FragmentTransaction ft)
		{
			// TODO Auto-generated method stub

		}

	};

	@Override
	public boolean onCreateOptionsMenu(Menu menu)
	{
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.my_action_bar, menu);
		return true;
	}

}
